
// <copyright file="XmlRichTextBoxSettings.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   Class XmlRichTextBoxSettings.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Windows.Forms
{
    using System.Drawing;
    using System.Text;

    /// <summary>
    ///     Class XmlRichTextBoxSettings.
    /// </summary>
    public class XmlRichTextBoxSettings
    {
        #region Constants

        /// <summary>
        ///     The attribute key unique identifier
        /// </summary>
        public const int AttributeKeyId = 3;

        /// <summary>
        ///     The attribute value unique identifier
        /// </summary>
        public const int AttributeValueId = 4;

        /// <summary>
        ///     The element unique identifier
        /// </summary>
        public const int ElementId = 1;

        /// <summary>
        ///     The tag unique identifier
        /// </summary>
        public const int TagId = 5;

        /// <summary>
        ///     The value unique identifier
        /// </summary>
        public const int ValueId = 2;

        #endregion Constants

        #region Public Properties

        /// <summary>
        ///     The color of an Attribute Key in Xml element.
        /// </summary>
        /// <value>The attribute key.</value>
        public Color AttributeKey { get; set; }

        /// <summary>
        ///     The color of an Attribute Value in Xml element.
        /// </summary>
        /// <value>The attribute value.</value>
        public Color AttributeValue { get; set; }

        /// <summary>
        ///     The color of an Xml element name.
        /// </summary>
        /// <value>The element.</value>
        public Color Element { get; set; }

        /// <summary>
        ///     Gets or sets the tag.
        /// </summary>
        /// <value>The tag.</value>
        public Color Tag { get; set; }

        /// <summary>
        ///     The color of an Xml element value.
        /// </summary>
        /// <value>The value.</value>
        public Color Value { get; set; }

        #endregion Public Properties

        #region Public Methods and Operators

        /// <summary>
        ///     Convert the settings to Rtf color definitions.
        /// </summary>
        /// <returns>System.String.</returns>
        public string ToRtfFormatString()
        {
            // The Rtf color definition format.
            const string format = @"\red{0}\green{1}\blue{2};";

            var rtfFormatString = new StringBuilder();

            rtfFormatString.AppendFormat(format, this.Element.R, this.Element.G, this.Element.B);
            rtfFormatString.AppendFormat(format, this.Value.R, this.Value.G, this.Value.B);
            rtfFormatString.AppendFormat(format, this.AttributeKey.R, this.AttributeKey.G, this.AttributeKey.B);
            rtfFormatString.AppendFormat(format, this.AttributeValue.R, this.AttributeValue.G, this.AttributeValue.B);
            rtfFormatString.AppendFormat(format, this.Tag.R, this.Tag.G, this.Tag.B);

            return rtfFormatString.ToString();
        }

        #endregion Public Methods and Operators
    }
}
